<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>


<script type="text/javascript">

var levelids = $$('#user_level_ids-wrapper');
var networkids = $$('#user_network_ids-wrapper');
var profileids = $$('#user_profile_ids-wrapper');

function badge_field_ids_reload()
{

  
    if( ($$('input[id=user_level_settings-1]:checked').length) ){
        levelids.setStyle('display','block');
    } else {
        levelids.setStyle('display','none');
    }

    if( ($$('input[id=user_network_settings-1]:checked').length) ){
        networkids.setStyle('display','block');
    } else {
        networkids.setStyle('display','none');
    }
    
    if( ($$('input[id=user_profile_settings-1]:checked').length) ){
        profileids.setStyle('display','block');
    } else {
        profileids.setStyle('display','none');
    }
}

  window.addEvent('domready', function(){
    var mapping_fields = $$('#members_order-wrapper, \
                  #heading1-wrapper, \
                  #user_profile_photo-wrapper, \
                  #user_view_count-wrapper, \
                  #user_invites_used-wrapper, \
                  #user_account_age-wrapper, \
                  #user_level_settings-wrapper, \
                  #user_level_ids-wrapper, \
                  #user_network_settings-wrapper, \
                  #user_network_ids-wrapper, \
                  #user_profile_settings-wrapper, \
                  #user_profile_ids-wrapper, \
                  #include_user_ids-wrapper, \
                  #exclude_user_ids-wrapper');

    var award_fields = $$('#awards_order-wrapper, \
            #heading1-wrapper, \
            #user_profile_photo-wrapper, \
            #user_view_count-wrapper, \
            #user_invites_used-wrapper, \
            #user_account_age-wrapper, \
            #user_level_settings-wrapper, \
            #user_level_ids-wrapper, \
            #user_network_settings-wrapper, \
            #user_network_ids-wrapper, \
            #user_profile_settings-wrapper, \
            #user_profile_ids-wrapper, \
            #award_member_request-wrapper, \
            #award_members_simple-wrapper');
                  
    ////////////
                          

    
    $$('input[name=user_level_settings]').addEvent('change', function(){
      if( !this.checked ) return;
      if( this.value == 1 ){
        levelids.setStyle('display','block');
      } else {
        levelids.setStyle('display','none');
      }
    });


    $$('input[name=user_network_settings]').addEvent('change', function(){
      if( !this.checked ) return;
      if( this.value == 1 ){
        networkids.setStyle('display','block');
      } else {
        networkids.setStyle('display','none');
      }
    });


    $$('input[name=user_profile_settings]').addEvent('change', function(){
      if( !this.checked ) return;
      if( this.value == 1 ){
        profileids.setStyle('display','block');
      } else {
        profileids.setStyle('display','none');
      }
    });


    badge_field_ids_reload();
    
    ////////////
                   
    if( ($$('input[id=membership_type-<?php echo Badge_Model_Badge::MEMBERSHIP_TYPE_MAPPING;?>]:checked').length) ){
      award_fields.setStyle('display','none');
      mapping_fields.setStyle('display','block');
      badge_field_ids_reload();
    } else {
      mapping_fields.setStyle('display','none');
      award_fields.setStyle('display','block');
      badge_field_ids_reload();
    }

    $$('input[name=membership_type]').addEvent('change', function(){
      if( !this.checked ) return;
      if( this.value == '<?php echo Badge_Model_Badge::MEMBERSHIP_TYPE_MAPPING;?>' ){
    	  award_fields.setStyle('display','none');
        mapping_fields.setStyle('display','block');
        badge_field_ids_reload(); 
      } else {
        mapping_fields.setStyle('display','none');
        award_fields.setStyle('display','block');
        badge_field_ids_reload();
      }
      
    });

  });

</script>